package fr.umlv.m2.jee.portailEtudiant.service.Impl;

import fr.umlv.m2.jee.portailEtudiant.persistence.ITdDAO;
import fr.umlv.m2.jee.portailEtudiant.persistence.Td;
import fr.umlv.m2.jee.portailEtudiant.service.DisplayTd;
import fr.umlv.m2.jee.portailEtudiant.service.IDisplayTdService;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.beans.factory.annotation.Qualifier;
import org.springframework.stereotype.Service;
import org.springframework.transaction.annotation.Transactional;

import java.util.ArrayList;
import java.util.List;

/**
 * Created by IntelliJ IDEA.
 * User: soufiane
 * Date: 07/02/11
 * Time: 02:06
 * To change this template use File | Settings | File Templates.
 */
@Service("defaultDisplayTdService")
public class DefaultDisplayTdService implements IDisplayTdService {

    @Autowired
    @Qualifier("hibernateTdDAO")
    private ITdDAO tdDao;

    @Transactional(readOnly=true)
    public List<DisplayTd> getAllDisplayTds() {
        List< DisplayTd > result = new ArrayList<DisplayTd>();

        for(Td td : tdDao.findAll()) {
            result.add(new DisplayTd(td));
        }
        return result;
    }
}
